package Handler;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LoginHandler
 */
@WebServlet("/LoginHandler")
public class LoginHandler extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LoginHandler() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("llega a metodo get");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("_user"); 		
		if (username.equals("vehiculos")){
			response.sendRedirect("HomeVehiculos.jsp");
		}
		else if (username.equals("seguridad")){
			response.sendRedirect("HomeSeguridad.jsp");
		}
		else if (username.equals("invitado")){
			response.sendRedirect("HomeInvitado.jsp");
		}
		else{
			response.sendRedirect("Login.jsp");			
		}
		
	}


}
